/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package koneksi;

import java.sql.Connection;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;

public class CekKoneksi {

     public static Connection open() {
        String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:XE";
        String userId = "HR"; // gantikan dengan username anda
        String password = "HR"; // gantikan dengan password anda
        Connection conn = null;
        try {
            OracleDataSource ods = new OracleDataSource();
            ods.setURL(jdbcUrl);
            conn = ods.getConnection(userId, password);
            Statement stat = conn.createStatement();
            System.out.println("Connection OK");
        } catch (Exception e) {
            System.out.println("error: " + e.getMessage());
        }
        return conn;
    }
}
